package com.ztgf.order.models.service.purchase;

import com.baomidou.mybatisplus.plugins.Page;
import com.baomidou.mybatisplus.service.IService;
import com.ztgf.common.constant.Result;
import com.ztgf.file.models.bo.FileInfoSaveBO;
import com.ztgf.order.models.bo.purchase.*;
import com.ztgf.order.models.dto.purchase.PurchaseInfoDTO;
import com.ztgf.order.models.vo.purchase.PurchaseCommodityBargainVO;
import com.ztgf.order.models.vo.purchase.PurchaseInfoExportVO;
import com.ztgf.order.models.vo.purchase.PurchaseInfoVO;
import com.ztgf.shopping.models.dto.audit.AuditDTO;
import com.ztgf.shopping.models.dto.shop.ShopSysInvoiceDTO;

import java.math.BigDecimal;
import java.util.List;

/**
 * 采购信息表服务
 *
 * @author mxli
 * @Date 2021-05-17 10:15:52
 */
public interface IPurchaseInfoService extends IService<PurchaseInfoDTO> {

    void add(PurchaseInfoSaveBO saveBO);

    void add(PurchaseInfoSaveBO saveBO,FileInfoSaveBO fileInfoBO);

    void add(PurchaseInfoSaveBO saveBO,AuditDTO auditDTO);

    /**
     * 卖家报价
     * @param saveBO
     * @return
     */
    Result saveSellBargain(PurchaseCommodityBargainSaveBO saveBO);


    /**
     * 维持原价
     * @param purchaseCommodityBargainId
     * @return
     */
    Result saveSellBargainOld(Long purchaseCommodityBargainId);


    /**
     * 接受议价
     * @param purchaseCommodityBargainId
     * @return
     */
    Result saveSellAcceptBargain(Long purchaseCommodityBargainId);

    /**
     * 买家议价
     * @param purchaseCommodityId
     * @param price
     * @return
     */
    Result saveBuyBargain(Long purchaseCommodityId, BigDecimal price);

    /**
     * 平台议价
     * @param purchaseCommodityId
     * @param price
     * @return
     */
    Result saveOwnBargain(Long purchaseCommodityId, BigDecimal price);

    /**
     * 取消报价
     * @param purchaseIds
     * @param cancelType
     * @param cancelDescription
     * @return
     */
    Result saveCanceBargain(String purchaseIds, Integer cancelType, String cancelDescription);

    /**
     * 平台取消报价
     * @param purchaseIds
     * @param cancelType
     * @param cancelDescription
     * @return
     */
    Result saveOwnCancelBargain(String purchaseIds, Integer cancelType, String cancelDescription);

    /**
     * 拒绝议价
     * @param purchaseCommodityBargainIds
     * @return
     */
    Result saveBuyRefuseBargain(String purchaseCommodityBargainIds);

    /**
     * 平台拒绝议价
     * @param purchaseCommodityBargainIds
     * @return
     */
    Result saveOwnRefuseBargain(String purchaseCommodityBargainIds);

    /**
     * 申请平台报价
     * @param platBargain
     * @return
     */
    Result savePlatBargain(String platBargain);

    /**
     * 平台砍价
     * @param purchaseCommodityBargainId
     * @return
     */
    Result savePlatBargain(Long purchaseCommodityBargainId);

    /**
     * 询价完成 触发条件 手动取消、手动完成、时间到期
     * @param purchaseInfoDTO
     * @param optType 0手动、1系统
     * @param userId
     * @param userName
     */
    public void saveFinishPurchaseInfo(PurchaseInfoDTO purchaseInfoDTO, int optType, Long userId, String userName, Integer cancelType, String cancelDescription, Long shopId);

    /**
     * 加入购物车
     * @param purchaseCommodityBargainIds
     * @return
     */
    Result saveShoppingCart(String purchaseCommodityBargainIds);

    /**
     * 立即购买
     * @param purchaseCommodityBargainId
     * @return
     */
    Result saveBuy(Long purchaseCommodityBargainId);

    /**
     * 修改主办人
     * @param id
     * @param sysUserId
     * @return
     */
    Result updateOrganiser(Long id, Long sysUserId);

    /**
     * 获取买家列表
     * @param bo
     * @return
     */
    Result<Page<PurchaseInfoVO>> queryBuyPageList(PurchaseInfoBuyBO bo);

    /**
     * 根据id查看买家详情
     * @param id
     * @return
     */
    Result<PurchaseInfoVO> getBuy(Long id);

    /**
     * 获取卖家列表
     * @param bo
     * @return
     */
    Result<Page<PurchaseInfoVO>> querySellPageList(PurchaseInfoSellBO bo);

    /**
     * 根据id查看卖家详情
     * @param id
     * @return
     */
    Result<PurchaseInfoVO> getSell(Long id);

    /**
     * 获取首页列表
     * @return
     */
    Result<Page<PurchaseInfoVO>> queryHomePageList(PurchaseInfoHomeBO bo);

    /**
     * 获取首页列表
     * @return
     */
    Result<Page<PurchaseInfoVO>> queryCmsHomePageList(PurchaseInfoHomeBO bo);

    /**
     * 根据id查看首页详情
     * @param id
     * @return
     */
    Result<PurchaseInfoVO> getHome(Long id);

    /**
     * 平台自己发布列表
     * @param bo
     * @return
     */
    Result<Page<PurchaseInfoVO>> queryOwnPageList(PurchaseInfoOwnBO bo);

    /**
     * 平台自己发布详情
     * @param id
     * @return
     */
    Result<PurchaseInfoVO> getOwn(Long id);
    /**
     * admin查看所有列表
     * @param bo
     * @return
     */
    Result<Page<PurchaseInfoVO>> queryAdminPageList(PurchaseInfoAdminBO bo);

    /**
     * admin查看详情
     * @param id
     * @return
     */
    Result<PurchaseInfoVO> getAdmin(Long id);

    /**
     * 查询申请平台砍价列表
     * @param bo
     * @return
     */
    Result<Page<PurchaseInfoVO>> queryPlatBargainPageList(PurchaseInfoPlatBargainBO bo);

    /**
     * 查询申请平台砍价详情
     * @param id
     * @return
     */
    Result<PurchaseInfoVO> getPlatBargain(Long id);

    /**
     * 获取报价商品详情
     * @param id
     * @return
     */
    Result<PurchaseCommodityBargainVO> getCommodityBargain(Long id,Long brandId,Long shopId);

    /**
     * 获取报价单信息（相似商品）
     * @param id
     * @return
     */
    Result<PurchaseInfoVO> getPurchaseInfo(Long id);

    /**
     * 代客下单
     * @param purchaseCommodityBargainIds
     * @return
     */
    Result saveAgentOrder(String purchaseCommodityBargainIds);

    /**
     * 根据报价商品id获取详情
     * @param purchaseCommodityBargainIds
     * @return
     */
    Result<List<PurchaseCommodityBargainVO>> queryCommodityBargainList(String purchaseCommodityBargainIds);

    /**
     * 导出买家报价单列表
     * @param bo
     * @return
     */
    List<PurchaseInfoExportVO> queryExportBuyList( PurchaseInfoBuyBO bo);

    /**
     * 导出卖家报价单列表
     * @param bo
     * @return
     */
    List<PurchaseInfoExportVO> queryExportSellList(PurchaseInfoSellBO bo);

    /**
     * 导出平台发布报价单列表
     * @param bo
     * @return
     */
    List<PurchaseInfoExportVO> queryExportOwnList(PurchaseInfoOwnBO bo);

    /**
     * 导出admin报价单列表
     * @param bo
     * @return
     */
    List<PurchaseInfoExportVO> queryExportAdminList(PurchaseInfoAdminBO bo);

    /**
     * 导入询价单
     * @param saveBO
     * @return
     */
    Result saveImportPurchase(PurchaseInfoImportSaveBO saveBO, byte[] input, FileInfoSaveBO fileInfoSaveBO);

    /**
     * 解析导入询价单的excel
     * @param saveBO
     * @param input
     * @return
     */
    public Result analyzePurchaseExcel(PurchaseInfoImportSaveBO saveBO, byte[] input);


    /**
     * 同步固定申请平台砍价固定费率29.8（买家）
     * @return
     */
    List<ShopSysInvoiceDTO> getSynchronizationShopSysInvoiceBuy();

    /**
     * admin导出平台砍价列表
     * @param bo
     * @return
     */
    List<PurchaseInfoExportVO> queryExportPlatBargainList(PurchaseInfoPlatBargainBO bo);
}
